package com.terrence.sso.token.server.service;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

import com.terrence.sso.token.server.Constant;

public final class SidCookieService {
	
	private SidCookieService(){};

	public static String getSid(HttpServletRequest httpRequest){
		String sid = null;
		Cookie[] cookies = httpRequest.getCookies();
        if (null != cookies) {
            for (Cookie cookie : cookies) {
                if (Constant.COOKIE_NAME.equals(cookie.getName())) {
                	sid = cookie.getValue();
                    break;
                }
            }
        }
        return sid;
	}

}
